package process;

import Controllers.RootController;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import memory.*;



public class ProcessManager {
	Stage primaryStage;
	private CPU cpu;		//对应的CPU
	public ProcessManager() {
		try {
			primaryStage = new Stage();
			FXMLLoader loader = new FXMLLoader();
			loader.setLocation(getClass().getResource("ProcessManagerFXML.fxml"));
			Parent root = (Parent)loader.load();
			Scene scene = new Scene(root);
			primaryStage.setScene(scene);
			primaryStage.setTitle("进程管理");
			primaryStage.setResizable(false);
			 primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
		            @Override
		            public void handle(WindowEvent event) {
		            	primaryStage.hide();
		            }
		          });
			cpu=CPU.getCpu();
			new java.lang.Thread(() -> {
	            cpu.run();
	        }).start();
			//root.setVisible(false);
			
			
//			测试用例
			CPU.getCpu().create("x=52"
					+ "x++"
					+ "x--"
					+ "x++"
					+ "x--"
					+ "end");
//			测试用例
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	public void setprimaryStage() {
		this.primaryStage.show();
	}
}
	
/*	
	@Override
	public void start(Stage primaryStage) throws Exception {
		
		FXMLLoader fxmlLoader = new FXMLLoader();
		Parent processParent = fxmlLoader.load(getClass().getResource("ProcessManagerFXML.fxml"));
		Scene processScene = new Scene(processParent);
		primaryStage.setScene(processScene);
		primaryStage.setTitle("进程管理");
		primaryStage.show();
		cpu=CPU.getCpu();
		new java.lang.Thread(() -> {
            cpu.run();
        }).start();
		
//		测试用例
		CPU.getCpu().create("x=52"
				+ "x++"
				+ "x--"
				+ "x++"
				+ "x--"
				+ "end");
//		测试用例
	}
	
	
	public static void main(String[] args) {
		launch(args);
	}*/

